/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tpdisenio2009.services;

import java.util.List;
import tpdisenio2009.model.beans.FantasyTeam;
import tpdisenio2009.model.beans.FantasyTeamScoreByTournamentDate;
import tpdisenio2009.model.beans.TournamentDate;
import tpdisenio2009.model.dao.FantasyTeamScoreByTournamentDateDAO;

/**
 *
 * @author DeuterioX
 */
public class FantasyTeamScoreByTournamentDateService {

    private final FantasyTeamScoreByTournamentDateDAO fantasyTeamScoreDAO;

    public FantasyTeamScoreByTournamentDateService() {
        fantasyTeamScoreDAO = new FantasyTeamScoreByTournamentDateDAO();
    }

    public void createFantasyTeamScoreByTournamentDate( FantasyTeamScoreByTournamentDate fantasyTeamScore ) {
        fantasyTeamScoreDAO.insert( fantasyTeamScore );
    }

    public int getFantasyTeamPositionByDate ( FantasyTeam fantasyTeam , TournamentDate date ) {
        return fantasyTeamScoreDAO.getFantasyTeamPositionByDate( fantasyTeam, date );
    }

    public int getFantasyTeamTotalPositionByDate ( FantasyTeam fantasyTeam , TournamentDate date ) {
        return fantasyTeamScoreDAO.getFantasyTeamTotalPositionByDate( fantasyTeam, date );
    }

    public Integer getFantasyTeamPointsByDate( FantasyTeam team, TournamentDate date ) {
        try {
            return fantasyTeamScoreDAO.getFantasyTeamPointsByDate( team, date ).getScore();
        } catch (Exception e) {
            return 0;
        }
    }

    public List<FantasyTeamScoreByTournamentDate> getFantasyTeamScoresByTournamentDate( TournamentDate date, int page  ) {
        return fantasyTeamScoreDAO.getFantasyTeamScoresByTournamentDate( date, page );
    }

    public List<FantasyTeamScoreByTournamentDate> getFantasyTeamScoresByTournamentDate( TournamentDate date ) {
        return fantasyTeamScoreDAO.getFantasyTeamScoresByTournamentDate( date );
    }

}
